<!DOCTYPE HTML>
<html>
<head>
    <title>Todo</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/editor/common.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 100%">
<div id="outImg">
    <img id="imgId" src="" alt="" onclick="smallImg()">
</div>
<div style="padding: 5px">
    <span>审核状态：</span><input id="status" class="mini-combobox"  data="userStatus" />

    <span>用户昵称：</span><input  class="mini-textbox" type="text" id="name"/>

    <span>用户id：</span><input  class="mini-textbox" type="text" id="objectId"/>

    <span>用户电话：</span><input  class="mini-textbox" type="text" id="tel"/>
    <a class="mini-button" iconCls="icon-search" onclick="search()">查找</a>
</div>
<div style="width:99%;">
    <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
        <table style="width:100%;">
            <tr>
                <td style="width:100%;">
                    <a class="mini-button" iconCls="icon-edit" onclick="shopEdit()">编辑</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<div id="datagrid1" class="mini-datagrid" style="width:99%;height: 82%;"
     url="/getdata/userStatus" idField="id" allowResize="true"
     sizeList="[20,30,50,100]" pageSize="30"
>
    <div property="columns">
        <div type="checkcolumn" ></div>
        <div field="objectId" width="120" headerAlign="center" allowSort="true" >objectId</div>
        <div field="name" width="80" headerAlign="center" allowSort="true" >用户姓名</div>
        <div field="holdIdentityCard"  width="70" align="center" headerAlign="center" renderer="onGenderRenderer" allowSort="true" >用户iocn</div>
        <div field="status" renderer="statusRenderer" align="center" width="60" headerAlign="center" allowSort="true">审核状态</div>
        <div field="identityCardNo" align="center" width="100" headerAlign="center" allowSort="true">身份证号码</div>
        <div field="reason"  width="100" align="center" headerAlign="center" allowSort="true">审核理由</div>
        <div field="tel" align="center" headerAlign="center" width="70" allowSort="true" >电话号码</div>
        <div field="createdAt" width="100" renderer="onBirthdayRenderer" align="center" headerAlign="center" allowSort="true">创建日期</div>
    </div>
</div>
</body>
<script type="text/javascript">
    var userStatus = [{ id: 1, text: '审核成功' }, { id: 0, text: '未审核'},{ id: 4, text: '审核失败'},{ id: 3, text: '审核中'}];
    var flag = 1;
    mini.parse();
    var grid = mini.get("datagrid1");
    grid.load();
    grid.on("drawcell", function (e) {
        var  value = e.value;
        column = e.column;
        //将性别文本替换成图片
        if (column.field == "holdIdentityCard") {
            if(value) {
                e.cellHtml = '<img class="bigImg" onclick="bigImg()" src="' + value + '?imageMogr2/thumbnail/640x/format/jpg/interlace/1/auto-orient" width="30" height="30" alt="图片">';
            }else{
                e.cellHtml = '<img class="bigImg" onclick="bigImg()"  src="http://7xiuo5.com1.z0.glb.clouddn.com/fgImage.png?imageMogr2/auto-orient/thumbnail/!100x100r/gravity/Center/crop/100x100/quality/80/auto-orient" width="30" height="30" alt="图片">';
            }
        }
    });

    function search() {
        var name = mini.get("name").getValue();
        var objectId = mini.get("objectId").getValue();
        var tel =mini.get("tel").getValue();
        var status = mini.get("status").getValue();
        if(name!=""||objectId!=""||tel!=""){
            status="";
        }else{
            status=status
        }
        grid.load({
            name: name,
            objectId:objectId,
            tel:tel,
            status: status
        });
    }
    $("#name,#objectId,#tel").bind("keydown", function (e) {
        if (e.keyCode == 13) {
            search();
        }
    });


    function shopEdit() {
        var row = grid.getSelected();
        if (row) {

            mini.open({
                url: "/getdata/userStatusEdit?id="+row.objectId,
                title: "编辑用户信息", width: 700, height: 400,

                ondestroy: function (action) {

                    grid.reload();

                }
            });

        } else {
            alert("请选中一条记录");
        }

    }

    function bigImg() {
        var row = grid.getSelected();
        if (row) {
            if(flag==1) {
                var path = row.holdIdentityCard;
                $("#imgId").attr('src', path);
                $("#outImg").css('display','block');
            }
        }
    }
    function smallImg() {
        $("#outImg").css('display','none');
    }


    function onBirthdayRenderer(e) {
        var value = e.value;
        if (value) return mini.formatDate(value, 'yyyy-MM-dd hh:mm:ss');
        return "";
    }
    function statusRenderer(e) {
        var value = e.value;
        if (value==true||value==1) {
            return (value, '审核成功')
        }else if(value==0){
            return (value, '未审核')
        }else if(value==4){
            return (value, '审核失败')
        }else if(value==3){
            return (value,'审核中')
        }
        return (value,'无状态')
    }
</script>
</html>